package com.wonderland.sail.exportexcel;

import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;

import java.io.IOException;
import java.io.OutputStream;

/**
 * excel对象
 */
public class ExcelVO {
    private String fileName;
    private String title;
    private int tableHeadRowNum;
    private String[] colTitle;
    private int[] width;
    private int[] align;
    //需要合计列的每个单元格在setCellValue的时候，参数必须为double类型的数据，即使用public void setCellValue(double value)方法
    private boolean[] sumFlag;

    //以下属性用于通过html导出excel
    private String htmlStr;//要转为excel的html串
    private int colNum;//总列数
    private String excelVersion;//excel版本：xls,xlsx

    //以下属性用于导出excel的返回值
    private Workbook workbook;
    private Sheet sheet;
    private OutputStream outputStream;

    public ExcelVO() {
        this.tableHeadRowNum = 1;
    }

    /**
     * @param fileName        文件名
     * @param title           标题
     * @param colTitle        表头
     * @param tableHeadRowNum 表头行数
     * @param width           各列宽
     * @param align           对齐方式
     * @param sumFlag         各列合计标志位,如果不需要可设置为null
     */
    public ExcelVO(String fileName, String title, int tableHeadRowNum, String[] colTitle, int[] width, int[] align, boolean[] sumFlag) {
        this.fileName = fileName;
        this.title = title;
        this.tableHeadRowNum = tableHeadRowNum;
        this.colTitle = colTitle;
        this.width = width;
        this.align = align;
        this.sumFlag = sumFlag;
    }

    public void workbookWriteOutSteam() throws IOException {
        if (this.workbook != null && this.outputStream != null) {
            workbook.write(outputStream);
        }
    }

    public String getFileName() {
        return fileName;
    }

    public void setFileName(String fileName) {
        this.fileName = fileName;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public int getTableHeadRowNum() {
        return tableHeadRowNum;
    }

    public void setTableHeadRowNum(int tableHeadRowNum) {
        this.tableHeadRowNum = tableHeadRowNum;
    }

    public String[] getColTitle() {
        return colTitle;
    }

    public void setColTitle(String[] colTitle) {
        this.colTitle = colTitle;
    }

    public int[] getWidth() {
        return width;
    }

    public void setWidth(int[] width) {
        this.width = width;
    }

    public int[] getAlign() {
        return align;
    }

    public void setAlign(int[] align) {
        this.align = align;
    }

    public boolean[] getSumFlag() {
        return sumFlag;
    }

    public void setSumFlag(boolean[] sumFlag) {
        this.sumFlag = sumFlag;
    }

    public String getHtmlStr() {
        return htmlStr;
    }

    public void setHtmlStr(String htmlStr) {
        this.htmlStr = htmlStr;
    }

    public int getColNum() {
        return colNum;
    }

    public void setColNum(int colNum) {
        this.colNum = colNum;
    }

    public String getExcelVersion() {
        return excelVersion;
    }

    public void setExcelVersion(String excelVersion) {
        this.excelVersion = excelVersion;
    }

    public Workbook getWorkbook() {
        return workbook;
    }

    public void setWorkbook(Workbook workbook) {
        this.workbook = workbook;
    }

    public Sheet getSheet() {
        return sheet;
    }

    public void setSheet(Sheet sheet) {
        this.sheet = sheet;
    }

    public OutputStream getOutputStream() {
        return outputStream;
    }

    public void setOutputStream(OutputStream outputStream) {
        this.outputStream = outputStream;
    }
}
